package com.dt.platform.oa.controller;

import java.math.BigDecimal;
import java.util.*;
import com.dt.platform.domain.oa.ProjectTask;
import com.dt.platform.domain.oa.meta.ProjectTaskMeta;
import com.github.foxnic.commons.lang.StringUtil;
import com.github.foxnic.sql.expr.ConditionExpr;
import org.github.foxnic.web.domain.hrm.Person;
import org.github.foxnic.web.framework.web.SuperController;
import org.github.foxnic.web.session.SessionUser;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import com.github.foxnic.commons.collection.CollectorUtil;
import com.github.foxnic.dao.entity.ReferCause;
import com.github.foxnic.api.swagger.InDoc;
import org.github.foxnic.web.framework.sentinel.SentinelExceptionUtil;
import com.github.foxnic.api.swagger.ApiParamSupport;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.dt.platform.proxy.oa.ProjectTaskRcdServiceProxy;
import com.dt.platform.domain.oa.meta.ProjectTaskRcdVOMeta;
import com.dt.platform.domain.oa.ProjectTaskRcd;
import com.dt.platform.domain.oa.ProjectTaskRcdVO;
import com.github.foxnic.api.transter.Result;
import com.github.foxnic.dao.data.SaveMode;
import com.github.foxnic.dao.excel.ExcelWriter;
import com.github.foxnic.springboot.web.DownloadUtil;
import com.github.foxnic.dao.data.PagedList;
import java.util.Date;
import java.sql.Timestamp;
import com.github.foxnic.api.error.ErrorDesc;
import com.github.foxnic.commons.io.StreamUtil;
import java.util.Map;
import com.github.foxnic.dao.excel.ValidateResult;
import java.io.InputStream;
import com.dt.platform.domain.oa.meta.ProjectTaskRcdMeta;
import org.github.foxnic.web.domain.hrm.Employee;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiImplicitParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.dt.platform.oa.service.IProjectTaskRcdService;
import com.github.foxnic.api.validate.annotations.NotNull;

/**
 * <p>
 * 工作记录接口控制器
 * </p>
 * @author 金杰 , maillank@qq.com
 * @since 2025-06-19 09:56:05
 */
@InDoc
@Api(tags = "工作记录")
@RestController("OaProjectTaskRcdController")
public class ProjectTaskRcdController extends SuperController {

    @Autowired
    private IProjectTaskRcdService projectTaskRcdService;

    /**
     * 添加工作记录
     */
    @ApiOperation(value = "添加工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.CT, value = "工作内容", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.E_TIME, value = "结束时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.ID, value = "主键", required = true, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.NOTES, value = "补充描述", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.OWNER_ID, value = "创建人员", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.PROJECT_ID, value = "关联项目", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.S_TIME, value = "开始时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.STATUS, value = "人员状态", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.TASK_ID, value = "关联任务", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.UPDATE_BY, value = "修改人ID", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TYPE, value = "工作类别", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TIME, value = "实际工时", required = false, dataTypeClass = BigDecimal.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_CATALOG, value = "工作类型", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.FILE_ID, value = "附件", required = false, dataTypeClass = String.class)
	})
    @ApiParamSupport(ignoreDBTreatyProperties = true, ignoreDefaultVoProperties = true, ignorePrimaryKey = true)
    @ApiOperationSupport(order = 1, author = "金杰 , maillank@qq.com")
    @SentinelResource(value = ProjectTaskRcdServiceProxy.INSERT, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.INSERT)
    public Result insert(ProjectTaskRcdVO projectTaskRcdVO) {
        Result result = projectTaskRcdService.insert(projectTaskRcdVO, false);
        return result;
    }

    /**
     * 删除工作记录
     */
    @ApiOperation(value = "删除工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.ID, value = "主键", required = true, dataTypeClass = String.class)
	})
    @ApiOperationSupport(order = 2, author = "金杰 , maillank@qq.com")
    @SentinelResource(value = ProjectTaskRcdServiceProxy.DELETE, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.DELETE)
    public Result deleteById(String id) {
        this.validator().asserts(id).require("缺少id值");
        if (this.validator().failure()) {
            return this.validator().getFirstResult();
        }
        // 引用校验
        ReferCause cause = projectTaskRcdService.hasRefers(id);
        // 判断是否可以删除
        this.validator().asserts(cause.hasRefer()).requireEqual("不允许删除当前记录：" + cause.message(), false);
        if (this.validator().failure()) {
            return this.validator().getFirstResult().messageLevel4Confirm();
        }
        Result result = projectTaskRcdService.deleteByIdLogical(id);
        return result;
    }

    /**
     * 批量删除工作记录 <br>
     * 联合主键时，请自行调整实现
     */
    @ApiOperation(value = "批量删除工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.IDS, value = "主键清单", required = true, dataTypeClass = List.class, example = "[1,3,4]")
	})
    @ApiOperationSupport(order = 3, author = "金杰 , maillank@qq.com")
    @SentinelResource(value = ProjectTaskRcdServiceProxy.DELETE_BY_IDS, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.DELETE_BY_IDS)
    public Result deleteByIds(List<String> ids) {
        // 参数校验
        this.validator().asserts(ids).require("缺少ids参数");
        if (this.validator().failure()) {
            return this.validator().getFirstResult();
        }
        // 查询引用
        Map<String, ReferCause> causeMap = projectTaskRcdService.hasRefers(ids);
        // 收集可以删除的ID值
        List<String> canDeleteIds = new ArrayList<>();
        for (Map.Entry<String, ReferCause> e : causeMap.entrySet()) {
            if (!e.getValue().hasRefer()) {
                canDeleteIds.add(e.getKey());
            }
        }
        // 执行删除
        if (canDeleteIds.isEmpty()) {
            // 如果没有一行可以被删除
            return ErrorDesc.failure().message("无法删除您选中的数据行：").data(0).addErrors(CollectorUtil.collectArray(CollectorUtil.filter(causeMap.values(), (e) -> {
                return e.hasRefer();
            }), ReferCause::message, String.class)).messageLevel4Confirm();
        } else if (canDeleteIds.size() == ids.size()) {
            // 如果全部可以删除
            Result result = projectTaskRcdService.deleteByIdsLogical(canDeleteIds);
            return result;
        } else if (canDeleteIds.size() > 0 && canDeleteIds.size() < ids.size()) {
            // 如果部分行可以删除
            Result result = projectTaskRcdService.deleteByIdsLogical(canDeleteIds);
            if (result.failure()) {
                return result;
            } else {
                return ErrorDesc.success().message("已删除 " + canDeleteIds.size() + " 行，但另有 " + (ids.size() - canDeleteIds.size()) + " 行数据无法删除").data(canDeleteIds.size()).addErrors(CollectorUtil.collectArray(CollectorUtil.filter(causeMap.values(), (e) -> {
                    return e.hasRefer();
                }), ReferCause::message, String.class)).messageLevel4Confirm();
            }
        } else {
            // 理论上，这个分支不存在
            return ErrorDesc.success().message("数据删除未处理");
        }
    }

    /**
     * 更新工作记录
     */
    @ApiOperation(value = "更新工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.CT, value = "工作内容", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.E_TIME, value = "结束时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.ID, value = "主键", required = true, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.NOTES, value = "补充描述", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.OWNER_ID, value = "创建人员", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.PROJECT_ID, value = "关联项目", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.S_TIME, value = "开始时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.STATUS, value = "人员状态", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.TASK_ID, value = "关联任务", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.UPDATE_BY, value = "修改人ID", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TYPE, value = "工作类别", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TIME, value = "实际工时", required = false, dataTypeClass = BigDecimal.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_CATALOG, value = "工作类型", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.FILE_ID, value = "附件", required = false, dataTypeClass = String.class)
	})
    @ApiParamSupport(ignoreDBTreatyProperties = true, ignoreDefaultVoProperties = true)
    @ApiOperationSupport(order = 4, author = "金杰 , maillank@qq.com", ignoreParameters = { ProjectTaskRcdVOMeta.PAGE_INDEX, ProjectTaskRcdVOMeta.PAGE_SIZE, ProjectTaskRcdVOMeta.SEARCH_FIELD, ProjectTaskRcdVOMeta.FUZZY_FIELD, ProjectTaskRcdVOMeta.SEARCH_VALUE, ProjectTaskRcdVOMeta.DIRTY_FIELDS, ProjectTaskRcdVOMeta.SORT_FIELD, ProjectTaskRcdVOMeta.SORT_TYPE, ProjectTaskRcdVOMeta.DATA_ORIGIN, ProjectTaskRcdVOMeta.QUERY_LOGIC, ProjectTaskRcdVOMeta.REQUEST_ACTION, ProjectTaskRcdVOMeta.IDS })
    @SentinelResource(value = ProjectTaskRcdServiceProxy.UPDATE, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.UPDATE)
    public Result update(ProjectTaskRcdVO projectTaskRcdVO) {
        Result result = projectTaskRcdService.update(projectTaskRcdVO, SaveMode.DIRTY_OR_NOT_NULL_FIELDS, false);
        return result;
    }

    /**
     * 保存工作记录
     */
    @ApiOperation(value = "保存工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.CT, value = "工作内容", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.E_TIME, value = "结束时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.ID, value = "主键", required = true, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.NOTES, value = "补充描述", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.OWNER_ID, value = "创建人员", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.PROJECT_ID, value = "关联项目", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.S_TIME, value = "开始时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.STATUS, value = "人员状态", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.TASK_ID, value = "关联任务", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.UPDATE_BY, value = "修改人ID", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TYPE, value = "工作类别", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TIME, value = "实际工时", required = false, dataTypeClass = BigDecimal.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_CATALOG, value = "工作类型", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.FILE_ID, value = "附件", required = false, dataTypeClass = String.class)
	})
    @ApiParamSupport(ignoreDBTreatyProperties = true, ignoreDefaultVoProperties = true)
    @ApiOperationSupport(order = 5, ignoreParameters = { ProjectTaskRcdVOMeta.PAGE_INDEX, ProjectTaskRcdVOMeta.PAGE_SIZE, ProjectTaskRcdVOMeta.SEARCH_FIELD, ProjectTaskRcdVOMeta.FUZZY_FIELD, ProjectTaskRcdVOMeta.SEARCH_VALUE, ProjectTaskRcdVOMeta.DIRTY_FIELDS, ProjectTaskRcdVOMeta.SORT_FIELD, ProjectTaskRcdVOMeta.SORT_TYPE, ProjectTaskRcdVOMeta.DATA_ORIGIN, ProjectTaskRcdVOMeta.QUERY_LOGIC, ProjectTaskRcdVOMeta.REQUEST_ACTION, ProjectTaskRcdVOMeta.IDS })
    @SentinelResource(value = ProjectTaskRcdServiceProxy.SAVE, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.SAVE)
    public Result save(ProjectTaskRcdVO projectTaskRcdVO) {
        Result result = projectTaskRcdService.save(projectTaskRcdVO, SaveMode.DIRTY_OR_NOT_NULL_FIELDS, false);
        return result;
    }

    /**
     * 获取工作记录
     */
    @ApiOperation(value = "获取工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.ID, value = "主键", required = true, dataTypeClass = String.class, example = "1")
	})
    @ApiOperationSupport(order = 6, author = "金杰 , maillank@qq.com")
    @SentinelResource(value = ProjectTaskRcdServiceProxy.GET_BY_ID, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.GET_BY_ID)
    public Result<ProjectTaskRcd> getById(String id) {
        Result<ProjectTaskRcd> result = new Result<>();
        ProjectTaskRcd projectTaskRcd = projectTaskRcdService.getById(id);
        projectTaskRcdService.dao().fill(projectTaskRcd).with(ProjectTaskRcdMeta.TASK).with(ProjectTaskRcdMeta.PROJECT).with(ProjectTaskRcdMeta.WORK_TYPE_DICT).with(ProjectTaskRcdMeta.OWNER).execute();
        projectTaskRcdService.dao().join(projectTaskRcd.getOwner(), Person.class);
        result.success(true).data(projectTaskRcd);
        return result;
    }

    /**
     * 批量获取工作记录 <br>
     * 联合主键时，请自行调整实现
     */
    @ApiOperation(value = "批量获取工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.IDS, value = "主键清单", required = true, dataTypeClass = List.class, example = "[1,3,4]")
	})
    @ApiOperationSupport(order = 3, author = "金杰 , maillank@qq.com")
    @SentinelResource(value = ProjectTaskRcdServiceProxy.GET_BY_IDS, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.GET_BY_IDS)
    public Result<List<ProjectTaskRcd>> getByIds(List<String> ids) {
        Result<List<ProjectTaskRcd>> result = new Result<>();
        List<ProjectTaskRcd> list = projectTaskRcdService.queryListByIds(ids);
        result.success(true).data(list);
        return result;
    }

    /**
     * 查询工作记录
     */
    @ApiOperation(value = "查询工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.CT, value = "工作内容", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.E_TIME, value = "结束时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.ID, value = "主键", required = true, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.NOTES, value = "补充描述", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.OWNER_ID, value = "创建人员", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.PROJECT_ID, value = "关联项目", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.S_TIME, value = "开始时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.STATUS, value = "人员状态", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.TASK_ID, value = "关联任务", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.UPDATE_BY, value = "修改人ID", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TYPE, value = "工作类别", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TIME, value = "实际工时", required = false, dataTypeClass = BigDecimal.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_CATALOG, value = "工作类型", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.FILE_ID, value = "附件", required = false, dataTypeClass = String.class)
	})
    @ApiOperationSupport(order = 5, author = "金杰 , maillank@qq.com", ignoreParameters = { ProjectTaskRcdVOMeta.PAGE_INDEX, ProjectTaskRcdVOMeta.PAGE_SIZE })
    @SentinelResource(value = ProjectTaskRcdServiceProxy.QUERY_LIST, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.QUERY_LIST)
    public Result<List<ProjectTaskRcd>> queryList(ProjectTaskRcdVO sample) {
        Result<List<ProjectTaskRcd>> result = new Result<>();
        List<ProjectTaskRcd> list = projectTaskRcdService.queryList(sample);
        result.success(true).data(list);
        return result;
    }

    /**
     * 分页查询工作记录
     */
    @ApiOperation(value = "分页查询工作记录")
    @ApiImplicitParams({
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.CT, value = "工作内容", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.E_TIME, value = "结束时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.ID, value = "主键", required = true, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.NOTES, value = "补充描述", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.OWNER_ID, value = "创建人员", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.PROJECT_ID, value = "关联项目", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.S_TIME, value = "开始时间", required = false, dataTypeClass = Date.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.STATUS, value = "人员状态", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.TASK_ID, value = "关联任务", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.UPDATE_BY, value = "修改人ID", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TYPE, value = "工作类别", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_TIME, value = "实际工时", required = false, dataTypeClass = BigDecimal.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.WORK_CATALOG, value = "工作类型", required = false, dataTypeClass = String.class),
		@ApiImplicitParam(name = ProjectTaskRcdVOMeta.FILE_ID, value = "附件", required = false, dataTypeClass = String.class)
	})
    @ApiOperationSupport(order = 8, author = "金杰 , maillank@qq.com")
    @SentinelResource(value = ProjectTaskRcdServiceProxy.QUERY_PAGED_LIST, blockHandlerClass = { SentinelExceptionUtil.class }, blockHandler = SentinelExceptionUtil.HANDLER)
    @PostMapping(ProjectTaskRcdServiceProxy.QUERY_PAGED_LIST)
    public Result<PagedList<ProjectTaskRcd>> queryPagedList(ProjectTaskRcdVO sample) {
        Result<PagedList<ProjectTaskRcd>> result = new Result<>();
        String cUserId = SessionUser.getCurrent().getActivatedEmployeeId();
        ConditionExpr expr = new ConditionExpr();
        expr.and("1=1");
        if (!StringUtil.isBlank(sample.getSelectRange())) {
            if ("mine".equals(sample.getSelectRange())) {
                // 只有项目中有指定，就可见
                expr.and("owner_id=?", cUserId);
            }
        }
        if (!StringUtil.isBlank(sample.getTabStatus())) {
            if ("mine".equals(sample.getTabStatus())) {
                expr.and("owner_id=?", cUserId);
            } else if ("other".equals(sample.getTabStatus())) {
                expr.and("owner_id<>?", cUserId);
            }
        }
        PagedList<ProjectTaskRcd> list = projectTaskRcdService.queryPagedList(sample, expr, sample.getPageSize(), sample.getPageIndex());
        projectTaskRcdService.dao().fill(list).with(ProjectTaskRcdMeta.TASK).with(ProjectTaskRcdMeta.PROJECT).with(ProjectTaskRcdMeta.WORK_TYPE_DICT).with(ProjectTaskRcdMeta.OWNER).execute();
        List<Employee> leaders = CollectorUtil.collectList(list, ProjectTaskRcd::getOwner);
        projectTaskRcdService.dao().join(leaders, Person.class);
        result.success(true).data(list);
        return result;
    }
}
